package com.maidada.mddaichat.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;

import java.util.List;

/**
 * @author wulinxuan
 * @date 2025-04-09 10:40
 */
@Data
public class PageResult<T> {

    private List<T> list;

    private Long total;

    public PageResult() {
    }

    public PageResult(List<T> list, Long total) {
        this.list = list;
        this.total = total;
    }

    public PageResult(IPage<T> pageResult) {
        this.list = pageResult.getRecords();
        this.total = pageResult.getTotal();
    }

    public static <T> PageResult<T> of(List<T> list, Long total) {
        return new PageResult<>(list, total);
    }

    public static <T> PageResult<T> of(IPage<T> pageResult) {
        return new PageResult<>(pageResult);
    }
}
